import { getAllList, getAmbulanceList } from '/@/components/chinaMap/chinaMapApi.ts';

export enum TabType {
    all = '', //所有资源
    youTianYiYuan = '1', //油田医院
    heZuoYiYuan = '2', //合作医院
    yiLiaoDian = '3', //医疗点
    jiuHuChe = '5', //救护车
    zhiShengJi = '4', //直升机
    diFangYiYuan = '6', //地方医院
}

export const tabList = [
    {
        name: '所有资源',
        type: TabType.all,
    },
    {
        name: '油田医院',
        type: TabType.youTianYiYuan,
    },
    {
        name: '医疗点',
        type: TabType.yiLiaoDian,
    },
    {
        name: '救护车',
        type: TabType.jiuHuChe,
    },
    {
        name: '合作医院',
        type: TabType.heZuoYiYuan,
    },
    {
        name: '地方医院',
        type: TabType.diFangYiYuan,
    },
    // {
    //     name: '直升机',
    //     type: TabType.zhiShengJi,
    // },
    {
        name: '急救路线',
    },
];

export const helicopter = new URL('/@/assets/img/helicopter.png', import.meta.url).href;
export const mapbg = new URL('/@/assets/img/helicopter.png', import.meta.url).href;
export const alarmIcon = new URL('/@/assets/img/alarm-icon.png', import.meta.url).href;
export const male = new URL('/@/assets/img/male.png', import.meta.url).href;
export const female = new URL('/@/assets/img/female.png', import.meta.url).href;
// 直升机位置数据
export const aircraft = [
    {
        category: 3,
        lon: '108.861377',
        lat: '34.35965',
        img: helicopter,
        name: '直升机',
    },
    {
        category: 3,
        lon: '106.267358',
        lat: '38.520079',
        img: helicopter,
        name: '直升机',
    },
    {
        category: 3,
        lon: '109.505282',
        lat: '36.579381',
        img: helicopter,
        name: '直升机',
    },
    {
        category: 3,
        lon: '107.638372',
        lat: '35.734218',
        img: helicopter,
        name: '直升机',
    },
];

/**
 * @desc 直升机文本
 */
export function aircraftContent() {
    return `
    <div style="display: flex;justify-content: center;align-items: center;">
        <div>
            <div style="display: flex;justify-content: center;">
                <div class="helicopter"></div>
            </div>
            <div style="z-index:999;background-color:#0A8B18;">
                <h5 style="overflow: hidden;font-size:18px;color:#fff;white-space: nowrap;padding:0 4px;">
                    4009-120-999
                </h5>
            </div>
        </div>
    </div>`;
}

export function mapApiSwitch(type, params: any) {
    const basicParams = {
        lat: 34, //纬度34
        lon: 108, //经度
    };
    // 全部 油田 医疗点 合作医院
    if ([TabType.all, TabType.youTianYiYuan, TabType.yiLiaoDian, TabType.heZuoYiYuan, TabType.jiuHuChe, TabType.jiuHuChe].includes(type)) {
        return getAllList({ ...basicParams, ...params });
    }
    // if ([TabType.jiuHuChe].includes(type)) {
    //     return getAmbulanceList({});
    // }
}

export const mapIcon1 = new URL('/@/assets/img/mapIcon1.png', import.meta.url).href;
export const mapIcon2 = new URL('/@/assets/img/mapIcon2.png', import.meta.url).href;
export const mapIcon3 = new URL('/@/assets/img/mapIcon3.png', import.meta.url).href;
export const mapIcon4 = new URL('/@/assets/img/mapIcon4.png', import.meta.url).href;
export const mapIcon5 = new URL('/@/assets/img/mapIcon5.png', import.meta.url).href;
export const mapIcon6 = new URL('/@/assets/img/mapIcon6.png', import.meta.url).href;
export const mapIcon7 = new URL('/@/assets/img/mapIcon7.png', import.meta.url).href;

export const legend1 = new URL('/@/assets/img/legend1.png', import.meta.url).href;
export const legend2 = new URL('/@/assets/img/legend2.png', import.meta.url).href;
export const legend3 = new URL('/@/assets/img/legend3.png', import.meta.url).href;
export const legend4 = new URL('/@/assets/img/legend4.png', import.meta.url).href;
export const legend5 = new URL('/@/assets/img/legend5.png', import.meta.url).href;

export const legendList = [
    { img: legend1, text: '油田医院' },
    { img: legend2, text: '医疗点' },
    { img: legend3, text: '救护车' },
    { img: legend4, text: '合作医院' },
    { img: legend5, text: '地方医院' },
];

/**
 * @description 秒转小时
 * */
export function convertSeconds(seconds: number) {
    let hours = Math.floor(seconds / 3600);
    let minutes = Math.floor((seconds % 3600) / 60);
    let remainingSeconds = seconds % 60;
    return {
        hours: hours,
        minutes: minutes,
        seconds: remainingSeconds,
    };
}

export function getTimeStr(time: number): string {
    let str = '';
    const { hours, minutes } = convertSeconds(time);
    if (hours) {
        str += hours + '小时';
    }
    if (minutes) {
        str += minutes + '分钟';
    }
    return str;
}

export function convertMetersToKilometers(meters: number): number {
    let kilometers = meters / 1000;
    return Math.round(kilometers * 100) / 100;
}

export function getKmStr(distance: number): string {
    if (!distance) return '';
    let d = convertMetersToKilometers(distance);
    return d >= 1 ? d + '公里' : d * 100 + '米';
}
